# -*- coding: utf-8 -*-
"""
创建日期: 2024/9/17   16:43

@author: justinc
@blog: https://blog.csdn.net/sjc122333?type=blog
@gitee: https://gitee.com/justinc666

"""
# 变态模式
list_ = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
# 常规写法1
list_1 = []
for i in list_:
    for j in i:
        if j % 2 == 0:
            list_1.append(j)

print(list_1)
# 常规写法2
list_2 = []
for i in list_:
    for j in i:
        if j % 2 == 0:
            list_2.append(j * j)

print(list_2)

list_ = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
# 列表推导式1
list_1 = [j for i in list_ for j in i if j % 2 == 0]
print(list_1)

list_2 = [j*j for i in list_ for j in i if j % 2 == 0]
print(list_2)